﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MagnOS.Command.ShellCommands
{
    class Shutdown
    {
        public void PrintHelp()
        {
            Console.WriteLine ("\n Shutdown [/? \\ -h]\nShutdown the computer");
        }

        public void Proceed(string[] args)
        {
            ConsoleKeyInfo cki;
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("WARNING: ");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Are you sure you want to shut down this computer? Press Y to confirm, or any other key to abort.\n");
            cki = Console.ReadKey(true);
            if (cki.KeyChar == 'y')
            {
                ACPIManager.ACPI.Shutdown();
            }
            else
            {
                Console.Write("Aborted\n");
            }
        }

        public void Execute(string[] args)
        {
            if (args[1] == "/?" || args[1] == "-h")
            {
                PrintHelp();
                return;
            }

            Proceed(args);
        }
    }
}
